package com.alliky.core.loader;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.alliky.core.R;
import com.alliky.core.util.StringUtils;

/**
 * ================================================
 *
 * @Description: 描述 Loading加载弹窗封装
 * @Author: wxianing
 * @Date: 2023/7/27 15:45
 * ================================================
 */
public class LoaderDialog extends Dialog {

    private Context mContext;
    private String message = "";

    public LoaderDialog(Context context) {
        super(context, R.style.dialog_loading);
        mContext = context;
    }

    public LoaderDialog(Context context, String message) {
        super(context, R.style.dialog_loading);
        mContext = context;
        this.message = message;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        View view = LayoutInflater.from(mContext).inflate(R.layout.loading_layout, null);
        TextView tv_message = view.findViewById(R.id.tv_message);
        if (StringUtils.isNotBlank(message)) {
            tv_message.setText(message);
        } else {
            tv_message.setVisibility(View.GONE);
        }
        setContentView(view);
    }
}
